/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('yicconsole', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model LxPopCmd {
  data?: string(name='data'),
}

model BillingProcessMessageRequest {
  body?: LxPopCmd(name='body'),
}

model BillingProcessMessageResponseBody = {
  message?: string(name='Message', example='CDR \\"job-347624039496835072\\" doesn\\"t exists.'),
  synchro?: boolean(name='Synchro', example='True'),
  code?: string(name='code', example='200'),
  data?: string(name='data', example='{}'),
  requestId?: string(name='requestId', description='Id of the request', example='63E17775-CA89-59DD-A8C0-FA26753A9556'),
  success?: boolean(name='success', example='True'),
}

model BillingProcessMessageResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: BillingProcessMessageResponseBody(name='body'),
}

async function billingProcessMessageWithOptions(request: BillingProcessMessageRequest, headers: map[string]string, runtime: Util.RuntimeOptions): BillingProcessMessageResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(request.body),
  };
  var params = new OpenApi.Params{
    action = 'BillingProcessMessage',
    version = '2024-01-18',
    protocol = 'HTTPS',
    pathname = `/yic/yic-console/v1/billing/commands/lifecycle`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function billingProcessMessage(request: BillingProcessMessageRequest): BillingProcessMessageResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return billingProcessMessageWithOptions(request, headers, runtime);
}

model CheckPayOrderRequest {
  body?: LxPopCmd(name='body'),
}

model CheckPayOrderResponseBody = {
  code?: string(name='code', example='200'),
  data?: string(name='data', example='{}'),
  message?: string(name='message', example='error'),
  requestId?: string(name='requestId', description='Id of the request', example='63E17775-CA89-59DD-A8C0-FA26753A9556'),
  success?: boolean(name='success', example='True'),
  synchro?: boolean(name='synchro', example='True'),
}

model CheckPayOrderResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CheckPayOrderResponseBody(name='body'),
}

async function checkPayOrderWithOptions(request: CheckPayOrderRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CheckPayOrderResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(request.body),
  };
  var params = new OpenApi.Params{
    action = 'CheckPayOrder',
    version = '2024-01-18',
    protocol = 'HTTPS',
    pathname = `/yic/yic-console/v1/billing/commands/verify`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function checkPayOrder(request: CheckPayOrderRequest): CheckPayOrderResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return checkPayOrderWithOptions(request, headers, runtime);
}

model CheckRefundRequest {
  body?: LxPopCmd(name='body'),
}

model CheckRefundResponseBody = {
  message?: string(name='Message', example='CDR \\"job-347624039496835072\\" doesn\\"t exists.'),
  synchro?: boolean(name='Synchro', example='True'),
  code?: string(name='code', example='200'),
  data?: string(name='data', example='{}'),
  requestId?: string(name='requestId', description='Id of the request', example='63E17775-CA89-59DD-A8C0-FA26753A9556'),
  success?: boolean(name='success', example='True'),
}

model CheckRefundResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CheckRefundResponseBody(name='body'),
}

async function checkRefundWithOptions(request: CheckRefundRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CheckRefundResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(request.body),
  };
  var params = new OpenApi.Params{
    action = 'CheckRefund',
    version = '2024-01-18',
    protocol = 'HTTPS',
    pathname = `/yic/yic-console/v1/billing/commands/check-refund`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function checkRefund(request: CheckRefundRequest): CheckRefundResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return checkRefundWithOptions(request, headers, runtime);
}

model PayOrderRequest {
  body?: LxPopCmd(name='body'),
}

model PayOrderResponseBody = {
  message?: string(name='Message', example='CDR \\"job-347624039496835072\\" doesn\\"t exists.'),
  synchro?: boolean(name='Synchro', example='True'),
  code?: string(name='code', example='200'),
  data?: string(name='data', example='{}'),
  requestId?: string(name='requestId', description='Id of the request', example='63E17775-CA89-59DD-A8C0-FA26753A9556'),
  success?: boolean(name='success', example='True'),
}

model PayOrderResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: PayOrderResponseBody(name='body'),
}

async function payOrderWithOptions(request: PayOrderRequest, headers: map[string]string, runtime: Util.RuntimeOptions): PayOrderResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(request.body),
  };
  var params = new OpenApi.Params{
    action = 'PayOrder',
    version = '2024-01-18',
    protocol = 'HTTPS',
    pathname = `/yic/yic-console/v1/billing/commands/pay`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function payOrder(request: PayOrderRequest): PayOrderResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return payOrderWithOptions(request, headers, runtime);
}

model PrepaidCeaseRequest {
  body?: LxPopCmd(name='body'),
}

model PrepaidCeaseResponseBody = {
  message?: string(name='Message', example='AccessDeniedByRamPolicy, ReqId:63FC296B4330433600DD89BC'),
  synchro?: boolean(name='Synchro', example='True'),
  code?: string(name='code', example='200'),
  data?: string(name='data', example='{}'),
  requestId?: string(name='requestId', description='Id of the request', example='63E17775-CA89-59DD-A8C0-FA26753A9556'),
  success?: boolean(name='success', example='True'),
}

model PrepaidCeaseResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: PrepaidCeaseResponseBody(name='body'),
}

async function prepaidCeaseWithOptions(request: PrepaidCeaseRequest, headers: map[string]string, runtime: Util.RuntimeOptions): PrepaidCeaseResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(request.body),
  };
  var params = new OpenApi.Params{
    action = 'PrepaidCease',
    version = '2024-01-18',
    protocol = 'HTTPS',
    pathname = `/yic/yic-console/v1/billing/commands/prepaid-cease`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function prepaidCease(request: PrepaidCeaseRequest): PrepaidCeaseResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return prepaidCeaseWithOptions(request, headers, runtime);
}

model RefundRequest {
  body?: LxPopCmd(name='body'),
}

model RefundResponseBody = {
  message?: string(name='Message', example='AccessDeniedByRamPolicy, ReqId:63FC296B4330433600DD89BC'),
  synchro?: boolean(name='Synchro', example='True'),
  code?: string(name='code', example='200'),
  data?: string(name='data', example='{}'),
  requestId?: string(name='requestId', description='Id of the request', example='63E17775-CA89-59DD-A8C0-FA26753A9556'),
  success?: boolean(name='success', example='True'),
}

model RefundResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: RefundResponseBody(name='body'),
}

async function refundWithOptions(request: RefundRequest, headers: map[string]string, runtime: Util.RuntimeOptions): RefundResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(request.body),
  };
  var params = new OpenApi.Params{
    action = 'Refund',
    version = '2024-01-18',
    protocol = 'HTTPS',
    pathname = `/yic/yic-console/v1/billing/commands/refund`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function refund(request: RefundRequest): RefundResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return refundWithOptions(request, headers, runtime);
}

